$(function () {
    var admin_map = $("#admin_map").val(), laytpl, layer, tc = '#GalleryTemplate', tcb = '#Gallery_';
    layui.use(['layer', 'laytpl'], function () {
        layer = layui.layer;
        laytpl = layui.laytpl;
        $(".openGallery").click(function () {
            var c = $(this).attr('data-c'), n = $(this).attr('data-n'),
                v = $("#Gallery_" + n).find('.checkGallery_' + n).val(), h = 650,
                w = window.frames.frameElement.id.includes('layui-layer-iframe'), l = w ? parent.layer : layer;
            if ($(window).height() < h) h = ($(window).height() - 20);
            v = typeof (v) !== 'undefined' ? v : '';
            l.open({
                type: 2,
                area: ['1000px', h + 'px'],
                fix: false,
                maxmin: true,
                shadeClose: true,
                shade: 0.4,
                anim: 2,
                title: '选择图片',
                content: '/' + admin_map + '/gallery/open.html?c=' + c + "&n=" + n + '&v=' + v,
            });

        });
    });
    renderGallery = function (i, u, n) {
        var a = $, t = a(tc).html(), w = window.frames.frameElement.id.includes('layui-layer-iframe'),
            l = w ? parent.layer : layer;
        laytpl(t).render({data: u, name: n}, function (html) {
            a(tcb + n).html(html);
        });
        l.close(l.index)
    }
})
